package com.example.core.arch.response;

import com.example.core.arch.baseData.CodeConstants;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class BaseResponse<T> {

    private T data;

    private List<T> dataList;

    private String code;

    private String status;

    private String message;

    public static <T> BaseResponse<T> success(T data) {
        return BaseResponse.<T>builder().code(CodeConstants.SUCCESS_CODE).status(CodeConstants.SUCCESS).data(data).build();
    }

    public static <T> BaseResponse<T> success(List<T> dataList) {
        return BaseResponse.<T>builder().code(CodeConstants.SUCCESS_CODE).status(CodeConstants.SUCCESS).dataList(dataList).build();
    }

    public static <T> BaseResponse<T> fail(String message) {
        return BaseResponse.<T>builder().code(CodeConstants.FAIL_CODE).status(CodeConstants.FAIL).message(message).build();

    }
}
